//
//  ZZTCollectMoney.m
//  HPZZTong
//
//  Created by WenJun on 14-7-9.
//  Copyright (c) 2014年 Handpay. All rights reserved.
//

#import "ZZTCollectMoney.h"
#import "HPUIEngine.h"
#import "CSNValidator.h"
#import "ZZTongClientEngine.h"
#import "POSUIEngine.h"

@interface POSProcess()

- (void)encryptData;


@end

@implementation ZZTCollectMoney

- (void)beginWithDelegate:(id)delegate
{
    [CSNValidator validateCSNAndExcuteBlock:^(HPSwiperResult *swiperResult) {
        if (swiperResult.isSuccess)
        {
            [super beginWithDelegate:delegate];
        }
    } autoTip:YES];
}

- (id)init
{
    self = [super init];
    _plainCurrency = @"156";
    self.uiDelegate = POSUIENG;
    return self;
}

- (NSString *)joinMac
{
    if (self.icMode)
    {
        return [super joinMac];
    }
    return nil;
}

- (void)encryptData
{
    if (!self.encAmount)
    {
        [self setValue:[NSNumber numberWithInt:SwipeActionEncrypt] forKeyPath:@"currentAction"];
        LOG(@"encryptData plainAmount:%@",self.plainAmount);
        [self.currentSwiper encyptAmount:self.plainAmount factor:self.factor complete:^(HPSwiperResult *swiperResult) {
            if (swiperResult.isSuccess)
            {
                [self setValue:swiperResult.value forKeyPath:@"encAmount"];
                [super encryptData];
            }
            else
            {
                [self dealResult:swiperResult];
            }
        }];
    }
}

@end
